package com.tjmc.finance.controller;


import com.tjmc.finance.service.TransactionRecordsService;
import com.tjmc.recruit.common.security.annotation.Inner;
import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 支付结果通知
 */
@RestController
@RequestMapping("/pay/notify")
@Slf4j
@RequiredArgsConstructor
public class NotifyPayResultController {

    private final TransactionRecordsService payOrderInfoService;

    /**
     * 支付结果回调
     *
     * @param request 请求头
     * @return ResponseEntity
     * @throws Exception
     */
    @PostMapping("")
    @Inner(value = false)
    public ResponseEntity payResultNotify(HttpServletRequest request, @RequestBody String notifyData) throws Exception {
        log.info("开始接收微信异步支付结果...");
        return payOrderInfoService.payNotification(request,notifyData);
    }

}
